
package com.idealighter.game.games.happyfive.handler;

import com.idealighter.game.core.annotation.ResMsgHandler;
import com.idealighter.game.games.happyfive.HappyFivePlayer;
import com.idealighter.game.games.happyfive.message.ReqDealCardOverMsg;
import com.idealighter.game.games.happyfive.message.ResHiddenCardsMsg;
import com.idealighter.game.message.core.ResMessage;
import com.idealighter.game.robot.core.Player;
import com.idealighter.game.robot.handler.ResMessageHandler;
import com.idealighter.utils.code.RandCodeUtil;

import java.util.concurrent.TimeUnit;


@ResMsgHandler(507206)
public class ResHiddenCardsHandler implements ResMessageHandler {

  // private static final Logger LOG = LoggerFactory.getLogger(ResHiddenCardsHandler.class);

  @Override
  public void action(Player player, ResMessage message) {
    ResHiddenCardsMsg msg = (ResHiddenCardsMsg) message;
    HappyFivePlayer happyFivePlayer = (HappyFivePlayer) player;
    happyFivePlayer.curBet = 0;
    happyFivePlayer.cardList.addAll(msg.getCards());
    player.schedule(() -> player.sendMsg(new ReqDealCardOverMsg()), RandCodeUtil.random(3, 5),
        TimeUnit.SECONDS);
  }

}
